package com.example.jparepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class JpaProperties {

    @Autowired
    private Environment env;

    public Map<String, Object> getJpaProperties(String prefix) {
        Map<String, Object> properties = new HashMap<>();
        properties.put("hibernate.dialect", env.getProperty(prefix + ".properties.hibernate.dialect"));
        properties.put("hibernate.hbm2ddl.auto", env.getProperty(prefix + ".hibernate.ddl-auto"));
        properties.put("hibernate.show_sql", env.getProperty(prefix + ".show-sql"));
        properties.put("hibernate.format_sql", env.getProperty(prefix + ".properties.hibernate.format_sql"));
        properties.put("hibernate.use_sql_comments", env.getProperty(prefix + ".properties.hibernate.use_sql_comments"));
        return properties;
    }
}
